package org.topdowntdd.sample.appfusemodularstruts.webapp.action.person;

import org.apache.struts2.config.Result;
import org.apache.struts2.dispatcher.ServletActionRedirectResult;
import org.topdowntdd.sample.appfusemodularstruts.model.Person;

import com.opensymphony.xwork2.Action;

@Result( name=Action.SUCCESS, value = "list", type=ServletActionRedirectResult.class )
public class DeleteAction extends BaseAction {

	private Person person;
	
	private DeleteAction _this = this;
	
	public void setSeam(DeleteAction seam) {
		_this = seam;
	}
	
	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	@Override
	public String execute() {
		personManager.remove(person.getId());
		
		String successMessage = _this.getText("person.delete.success");
		_this.saveMessage(successMessage);
		
		return SUCCESS;
	}

	@Override
	protected void saveMessage(String msg) {
		super.saveMessage(msg);
	}

	
}
